﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace Ewts.Storage
{
    public partial class BarCodeRepeat : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtWrlno.Value.Trim() == "")
            {
                DataLib.Common.MessageBox.Show(Page, "请输入入库单号");
                txtWrlno.Focus();
                return;
            }

            string Wrlno = txtWrlno.Value.Trim();
            DataLib.Model.InStorage inModel= new DataLib.BLL.InStorage().GetModelByNo(Wrlno);
            if (inModel != null)
                bindData((int)inModel.id);
            else
                DataLib.Common.MessageBox.Show(Page, "当前入库单无记录");

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="wrlid"></param>
        /// <returns></returns>
        protected string DisWrlNo(string wrlid)
        {
            return txtWrlno.Value;
        }

        /// <summary>
        /// 绑定一张入库单号下的所有物品
        /// </summary>
        /// <param name="inSid"></param>
        protected void bindData(int inSid)
        {
            string where = "InStrorageID=" + inSid.ToString();
            DataTable dt = new DataLib.BLL.BarCode().GetList(where).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                rept.DataSource = dt;
                rept.DataBind();
            }
        }

        /// <summary>
        /// 获取入库时间
        /// </summary>
        /// <param name="inSid"></param>
        /// <returns></returns>
        protected string GetInDate(string inSid)
        {
            DataLib.Model.InStorage inModel = new DataLib.BLL.InStorage().GetModel(int.Parse(inSid));
            if (inModel != null)
                return inModel.instoragetime.ToString();
            else
                return null;
        }

        /// <summary>
        /// 根据入库编号获取链接用的文件名
        /// </summary>
        /// <param name="wrlno"></param>
        /// <returns></returns>
        protected string GetFileName()
        {
            string wrlno = txtWrlno.Value.Trim();
            string strFile = "BarcodeImg.aspx";     //默认是入库
            if (wrlno.IndexOf("M") == 0)
            {
                strFile = "BarCodeWRL.aspx";                       //M为临时库
            }
            return strFile;
        }

       
    }
}